package com.lminkey.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet( "/admin/checkusernum")
public class CheckUserNum extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       //设置字符集
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

        String num = request.getParameter("num");
        //在CodeServel中获取session的值
        HttpSession session = request.getSession();
        String syscode = (String)session.getAttribute("code");

        System.out.println(syscode+"&&"+num);

        PrintWriter out = response.getWriter();
        if (syscode.equals(num)){
            out.print("true");
        }else {
            out.print("false");
        }
        out.close();
    }
}
